#include <iostream>
using namespace std;

/*
//静态成员函数
 class A{
 public:
     A(int a = 0){
         ++count;
     }
     A(const A& aa){
         ++count;
     }
     static int GetCount(){
         //a++;//不能直接访问非静态成员
         return count;
     }

     static int count;//类中只是声明
 private:
     int a = 0;
 };

 int A::count = 0;//静态成员变量必须在类外定义，不加关键字

void test1(){
    A aa1;
    A aa2(aa1);
    A aa3 = 1;
    A aa4[10];
    cout << A::count << endl;
    cout << aa1.count << endl;
    cout << aa2.count << endl;
}
*/

/*
class A{
private:
    static int k;
    int h = 1;
public:
    //内部类：跟A是独立（空间），只是受A的类域限制
    class B{
    public:
        static void func(const A& a){
            cout << k << endl;
            cout << a.h << endl;
        }
    private:
        int b = 2;
    };
};

int A::k = 2;

void test2(){
    A aa;
    cout << sizeof aa << endl;
}

class Solution{
private:
    class Sum{
    public:
        Sum(){
            _sum += _i;
            ++_i;
        }
    };
    static int _i;
    static int _sum;
public:
    static int Sum_Solution(int n){
        Sum a[n];
        return _sum;
    }
};

int Solution::_i = 1;
int Solution::_sum = 0;
*/

class A{
public:
    A(int a = 0)
    :_a(a){
        cout << "A(int a)" << endl;
    }
    A(const A& aa)
    :_a(aa._a){
        cout << "A(const A& aa)" << endl;
    }
    ~A(){
        cout << "~A()" << endl;
    }
private:
    int _a;
};

void func1(A aa){
}

void func2(const A& aa){
}

A func3(){
    A aa;
    return aa;
}

A func4(){
    return A();
}

/*
int main() {
    A aa1 = 1;
    func1(aa1);
    func1(1);
    func1(A(3));
    cout << "-------------------------" << endl;
    func2(aa1);
    func2(1);
    func2(A(3));
    return 0;
}
*/

/*
int main(){
    func3();
    A aa1 = func3();
    cout << "--------------------------" << endl;
    func4();
    A aa2 = func4();
    return 0;
}
*/

struct ListNode{
    int _val;
    ListNode* _next;
    ListNode(int val)
    :_val(val)
    ,_next(nullptr){}
};

/*
int main(){
    ListNode* n1 = new ListNode(1);
    ListNode* n2 = new ListNode(2);
}
*/

//JZ64 求1+2+3+...+n
//https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1?tpId=13&tqId=11200&tPage=3&rp=3&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking

#include <iostream>
using namespace std;

/*
class Sum{
public:
    Sum(){
        sum += count;
        ++count;
    }
    static int GetSum(){
        return sum;
    }
private:
    static int count;
    static int sum;
};

int Sum::count = 1;
int Sum::sum = 0;

class Solution{
public:
    static int Sum_Solution(int n){
        Sum A[n];
        return Sum::GetSum();
    }
};

void test1(){
    cout << Solution::Sum_Solution(10) << endl;
}

int main(){
    test1();
    return 0;
}
*/

/*
class Solution{
public:
    static int Sum_Solution(int n){
        Sum A[n];
        return _sum;
    }
private:
    class Sum{
    public:
        Sum(){
            _sum += _i;
            ++_i;
        }
    };
    static int _i;
    static int _sum;
};

int Solution::_i = 1;
int Solution::_sum = 0;

int main(){
    cout << Solution::Sum_Solution(100) << endl;
    return 0;
}
*/

//HJ73 计算日期到天数转换
//https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded?tpId=37&&tqId=21296&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking

/*
int main(){
    int year, month, day;
    cin >> year >> month >> day;
    int monthDay1_N[13] = {0,31,59,90,120,151,181,212,243,273,304,334,365};
    int nDay = monthDay1_N[month - 1];
    nDay += day;
    if (month > 2 &&((year%4==0 && year%100!=0) || year%400 == 0))
        nDay += 1;
    cout << nDay << endl;
}
*/

//日期差值

/*
int CountDat(int y, int m, int d){
    int monthDay1_N[13] = {0,31,59,90,120,151,181,212,243,273,304,334,365};
    int yearDay = 365*y + y/4 - y/100 + y/400;
    int monthDay = monthDay1_N[m-1];
    if (m > 2 &&((y%4==0 && y%100!=0) || y%400 == 0))
        monthDay += 1;
    return yearDay + monthDay + d;
}

int main(){
    int year1, month1, day1;
    scanf("%4d%2d%2d",&year1,&month1,&day1);
    int n1 = CountDat(year1,month1,day1);
    int year2, month2, day2;
    scanf("%4d%2d%2d",&year2,&month2,&day2);
    int n2 = CountDat(year2,month2,day2);
    cout << abs(n1-n2)+1 << endl;
}
*/

//打印日期
//给出年分m和一年中的第n天，算出第n天是几月几号

int main(){
    int year, day;
    int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    while (cin >> year >> day){
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
            month[1] = 29;
        else
            month[1] = 28;
        for (int i = 0; i < 12; ++i) {
            if (day > month[i])
                day -= month[i];
            else{
                printf("%04d-%02d-%02d\n",year,i+1,day);
                break;
            }
        }
    }
    return 0;
}
